#include <fontconfig/fontconfig.h>
#include <glib.h>

int
main(int argc, char* argv[])
{
    if (argc != 2) {
	g_print("Usage: %s <font file>\n", argv[0]);
	return -1;
    }

    int count;
    FcPattern* pat = FcFreeTypeQuery((FcChar8*)argv[1],
				     0, NULL, &count);
    if (!pat) {
	g_printerr("Query freetype failed\n");
	return -1;
    }

    FcChar8* fullname = FcPatternFormat(pat, (FcChar8*)"%{fullname}");
    FcPatternDestroy(pat);
    g_print("Fullname: %s\n", fullname);
    gchar** list = g_strsplit((gchar*)fullname, ",", -1);
    FcStrFree(fullname);
    g_print("Name: %s\n", list[0]);
    g_strfreev(list);

    return 0;
}
